package com.jianggy.proxy.jdk2;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author jianggy
 * @version 1.0
 * @time 2019/11/16 18:59
 * @see
 **/
public class SubjectInvocationHandler implements InvocationHandler {
    DynamicSubject subject;
    public SubjectInvocationHandler(DynamicSubject subject){
        this.subject = subject;
    }
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        long start = System.currentTimeMillis();
        System.out.println("代理类执行开始时间："+start);
        if (method.getName().equals("method1")){
            System.out.println("----------------");

        }else{
            System.out.println("===================");
        }
        long end = System.currentTimeMillis();
        System.out.println("代理类执行结束时间："+end);
        System.out.println("执行被代理类的方法共耗时："+(end-start)+"毫秒");
        return null;
    }
}
